<template>
    <el-dialog :visible.sync="show" title="选择NA-B方案" width="70%" @close="closeDialog">
        <el-form inline>
            <el-form-item>
                <el-input v-model="where.fDeviceModel" placeholder="请输入查询内容"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary">查询</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" style="width: 100%" @row-click="checkProduct">
            <el-table-column label="选择" width="50">
                <template slot-scope="scope">
                    <el-radio :value="checkData.fId" :label="scope.row.fId"></el-radio>
                </template>
            </el-table-column>  
            <el-table-column prop="fPlanCode" label="方案编码"></el-table-column>
            <el-table-column prop="fPlanName" label="方案名称"></el-table-column>
            <el-table-column label="方案介绍">
                <template slot-scope="scope">
                    <div>{{ scope.row.fRemark }}</div>
                </template>
            </el-table-column>
            <el-table-column label="添加日期">
                <template slot-scope="scope">
                    <div>{{ scope.row.fCreateDate}}</div>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="where.pageNum" :limit.sync="where.pageSize" @pagination="getList" />
        <div slot="footer" class="dialog-footer">
            <el-button @click="show = false">取 消</el-button>
            <el-button type="primary" @click="toSure">确认</el-button>
        </div>
    </el-dialog>
</template>

<script>
import {planLst} from '@/api/workOrder/administration'
export default {
    name: 'product',
    data() {
        return {
            show: false,
            where: {
                pageNum: 1,
                pageSize: 10,
                fDeviceModel: '',
                fProductId:localStorage.getItem('productId')
            },
            tableData: [],
            total: 0,
            checkData: {
            }
        }
    },
    methods: {
        open() {
            this.show = true
            this.getList()
        },
        closeDialog(){
            this.tableData = []
            this.where.pageNum = 1
            this.where.fDeviceModel = ''
        },
        getList() {
            this.where.fProductId = localStorage.getItem('productId')||-1
            planLst(this.where).then(res=>{
                this.tableData = res.rows
                this.total = res.total
            })
        },
        checkProduct(row) {
            this.checkData = row
        },
        toSure() {
            this.show = false
            this.$emit("sure",this.checkData)
        }
    }
}
</script>

<style lang="scss" scoped>

::v-deep .el-radio__label {
    display: none;
}
</style>